package com.kkb.controller;





import com.kkb.common.utils.AliSendSms;
import com.kkb.common.utils.VerificationCode;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class MessageController {

    @RequestMapping("/sms/code")
    @ResponseBody
    public void sms(HttpServletRequest request, HttpServletResponse response) throws ServletRequestBindingException {
        AliSendSms aliSendSms = new AliSendSms();
        String code = VerificationCode.getNumeral();
        String mobile = ServletRequestUtils.getRequiredStringParameter(request, "mobile");
        aliSendSms.aliSendSms(mobile, code);
    }

    @RequestMapping("/sms/login")
    @ResponseBody
    public void login(HttpServletRequest request, HttpServletResponse response) throws ServletRequestBindingException {
//        AliSendSms aliSendSms = new AliSendSms();
//        String code = VerificationCode.getNumeral();
//        String mobile = ServletRequestUtils.getRequiredStringParameter(request, "mobile");
//        aliSendSms.aliSendSms(mobile, code);
    }

}
